/*
 * @Author: ygl
 * @Date: 2021-12-16 15:41:27
 * @LastEditors: ygl
 * @LastEditTime: 2021-12-17 12:16:32
 * @Description: file content
 */
import { BrowserRouter, Routes, Route } from 'react-router-dom'
import { routeConfig } from './routerConfig'
import loadable from '@loadable/component'
/** 异步组件使用lazy()函数加载, 传递一个使用import()函数的Promise异步方法, 该方法最终返回import()函数的结果 */
// import Login from '../pages/Index'
const LoadableComponent = loadable((props) => import(`../${props.path}`))
export const MumuRouter = () => {
  return (
    <BrowserRouter>
      <Routes>
        {routeConfig.map((route) => {
          // const Element = require(route.component)
          console.log(route.component)
          return <Route path={route.path} element={<LoadableComponent path={route.component} />} key={route.id} />
        })}
      </Routes>
    </BrowserRouter>
  )
}
